package com.maochd.cloud.excel.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.maochd.cloud.excel.condition.ImportQueryCondition;
import com.maochd.cloud.excel.entity.ImportRecord;
import com.maochd.cloud.excel.mapper.ImportRecordMapper;
import com.maochd.cloud.excel.service.ImportRecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Objects;

@Service
public class ImportRecordServiceImpl extends ServiceImpl<ImportRecordMapper, ImportRecord> implements ImportRecordService {

    @Override
    public Page<ImportRecord> listByCondition(ImportQueryCondition condition) {
        return this.page(condition.orderWithPage(), Wrappers.<ImportRecord>lambdaQuery()
                .eq(Objects.nonNull(condition.getImportType()), ImportRecord::getImportType, condition.getImportType())
                .eq(Objects.nonNull(condition.getUserId()), ImportRecord::getUserId, condition.getUserId()));
    }
}
